<template>
  <div>
    <el-form ref="customerForm" :model="form" label-width="80px">
      <el-row>
        <el-col :md="7" :lg="7">
          <el-form-item label="客户姓名:">
            <el-input
              v-model="form.name"
              size="medium"
              placeholder="请输入客户姓名"
            />
          </el-form-item>
        </el-col>
        <el-col :md="7" :lg="7">
          <el-form-item label="客户电话:">
            <el-input
              v-model="form.tel"
              size="medium"
              placeholder="请输入客户电话"
            />
          </el-form-item>
        </el-col>
        <el-col :md="7" :lg="7">
          <el-form-item label="喜欢车型:">
            <el-select v-model="form.cartype0" placeholder="请选择" clearable>
              <el-option
                v-for="item in CarNameList()"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :md="3" :lg="3" style="text-align: right">
          <!-- <el-form-item> -->
          <el-button
            type="primary"
            size="medium"
            @click="onSubmit('customerForm')"
          >
            搜索
          </el-button>
          <!-- </el-form-item> -->
        </el-col>
      </el-row>
      <el-row>
        <el-col :md="7" :lg="7">
          <el-form-item label="创建日期:">
            <el-date-picker
              v-model="form.ctime"
              type="date"
              size="medium"
              placeholder="请选择日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
            />
          </el-form-item>
        </el-col>
        <el-col :md="7" :lg="7">
          <el-form-item label="预约日期:">
            <el-date-picker
              v-model="form.ordertime"
              type="date"
              size="medium"
              placeholder="请选择日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
import mixin from '@/mixin/mixin'
export default {
  name: 'CustomerForm',
  mixins: [mixin],
  data() {
    return {
      form: {
        name: '',
        tel: '',
        cartype0: '',
        ctime: '',
        ordertime: ''
      }
    }
  },
  methods: {
    onSubmit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$emit('on-success-valid', {
            name: this.form.name,
            tel: this.form.tel,
            cartype0: this.form.cartype0,
            ctime: this.form.ctime,
            ordertime: this.form.ordertime
          })
        } else {
          return false
        }
      })
    }
  }
}
</script>

<style scoped>
  /* .el-date-editor.el-input, .el-date-editor.el-input__inner {
    width: 100%;
  } */
  .el-input{
    width: 160px;
  }
</style>
